﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIScrollImage : MonoBehaviour
{
    public Vector2 velocity = Vector2.zero;
    public Vector2 offset = Vector2.zero;

    private Image image;

    private void Awake()
    {
        image = GetComponent<Image>();
        image.material = new Material(Shader.Find("UI/Unlit/Transparent"));
    }


    private void OnDestroy()
    {
        image.material = image.defaultMaterial;
    }

    // Update is called once per frame
    void Update()
    {
        offset -= velocity * Time.deltaTime;
        image.material.SetTextureOffset("_MainTex", offset);
    }
}
